"""
浏览器配置
"""
import datetime
import os
import sys

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from webdriver_manager.microsoft import EdgeChromiumDriverManager


class EdgeDriver:
    driver = ""

    def __init__(self):
        options = webdriver.EdgeOptions()
        options.page_load_strategy = "normal"
        self.driver = webdriver.Edge(service=Service(EdgeChromiumDriverManager().install()), options=options)
    def GetScreenShot(self):
        dirname = datetime.datetime.now().strftime("%Y-%m-%d") + "png"
        if not os.path.exits("../images/" + dirname):
            os.mkdir("../images/" + dirname)
        filename = sys.getframe().f_back.f_code.co_name + "-" + datetime.datetime.now().strftime("%Y-%m-%d-%H%M%S") + ".png"
        self.driver.save_screenshot("../images/" + dirname + "/" + filename)


